<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    #include("common/header.html")
</head>

<body>
<div style="margin: 15px;">
    <div class="layui-form" id="form">
        <div class="layui-form-item">
            <label class="layui-form-label">头像</label>
            <div class="layui-input-block">
                #if(!$info.headUrl)
                <img id="imgUrl" src="/images/timg.jpg" height="200px" width="200px">
                #else
                <img id="imgUrl" src="$!info.headUrl" data-src="$!info.headUrl" height="200px" width="200px">
                #end
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
                <input type="file" name="file" id="imgFile" class="layui-upload-file">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">昵称</label>
            <div class="layui-input-block">
                <input type="text" id="nickname" value="$!{info.nickname}" lay-verify="title" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">性别</label>
            <div class="layui-input-block">
                <select id="sex">
                    <option value="男">男</option>
                    <option value="女">女</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">生日</label>
            <div class="layui-input-block">
                <input type="text" name="date" id="birthday" value="$!date.format('yyyy-MM-dd',$!info.birthday)"
                       lay-verify="date"
                       placeholder="yyyy-mm-dd" autocomplete="off" class="layui-input"
                       onclick="layui.laydate({elem: this})">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">选择地区</label>
            <div class="layui-input-inline">
                <select id="province" name="province" lay-filter="province">
                    <option value="">请选择省</option>
                </select>
            </div>
            <div class="layui-input-inline" style="display: none;">
                <select id="city" name="city" lay-filter="city">
                    <option value="">请选择市</option>
                </select>
            </div>
            <div class="layui-input-inline" style="display: none;">
                <select id="area" name="area" lay-filter="area">
                    <option value="">请选择县/区</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">个人简介</label>
            <div class="layui-input-block">
                <textarea placeholder="个人简介" id="personalInfo" class="layui-textarea">$!{info.personalInfo}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">课程简介</label>
            <div class="layui-input-block">
                <textarea placeholder="课程简介" id="courseInfo" class="layui-textarea">$!{info.courseInfo}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">学历</label>
            <div class="layui-input-block">
                <input type="text" id="edu" name="title" value="$!{info.edu}" lay-verify="title" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">第二学历</label>
            <div class="layui-input-block">
                <input type="text" id="edu2" name="title" value="$!{info.edu2}" lay-verify="title" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">单位</label>
            <div class="layui-input-block">
                <input type="text" id="company" name="title" value="$!{info.company}" lay-verify="title"
                       autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">职称</label>
            <div class="layui-input-block">
                <input type="text" id="title" name="title" value="$!{info.title}" lay-verify="title" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">证书</label>
            <div class="layui-input-block">
                <input type="text" id="cert" name="title" value="$!{info.cert}" lay-verify="title" autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">现任职务</label>
            <div class="layui-input-block">
                <input type="text" id="duties" name="title" value="$!{info.duties}" lay-verify="title"
                       autocomplete="off"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">最高职务</label>
            <div class="layui-input-block">
                <input type="text" id="dutiesTop" name="title" value="$!{info.dutiesTop}" lay-verify="title"
                       autocomplete="off"
                       class="layui-input">
            </div>
        </div>
    </div>
</div>
<script>
    var areaData = Area;
    var $form;
    var form;
    var $;
    layui.use(['jquery','form','laydate', 'upload'], function() {
        $ = layui.jquery;
        form = layui.form();
        $form = $('#form');
        laydate = layui.laydate;
        loadProvince();

        layui.upload({
            url: '/upload/',
            elem: '#imgFile',
            success: function (res) {

                layer.msg(res.msg);

                if(res.code == -1){
                    return;
                }

                $("#imgUrl").attr("src","" + res.data);
                $("#imgUrl").attr("data-src",res.data);
                console.log(res); //上传成功返回值，必须为json格式
            }
        });
    });
    //加载省数据
    function loadProvince() {
        var proHtml = '';
        for (var i = 0; i < areaData.length; i++) {
            proHtml += '<option value="' + areaData[i].provinceCode + '_' + areaData[i].mallCityList.length + '_' + i + '" data="'+areaData[i].provinceName+'">' + areaData[i].provinceName + '</option>';
        }
        //初始化省数据
        $form.find('select[name=province]').append(proHtml);
        form.render();
        form.on('select(province)', function(data) {
            $form.find('select[name=area]').html('<option value="">请选择县/区</option>').parent().hide();
            var value = data.value;
            var d = value.split('_');
            var code = d[0];
            var count = d[1];
            var index = d[2];
            if (count > 0) {
                loadCity(areaData[index].mallCityList);
            } else {
                $form.find('select[name=city]').parent().hide();
            }
        });
    }
    //加载市数据
    function loadCity(citys) {
        var cityHtml = '';
        for (var i = 0; i < citys.length; i++) {
            cityHtml += '<option value="' + citys[i].cityCode + '_' + citys[i].mallAreaList.length + '_' + i + '" data="'+citys[i].cityName+'">' + citys[i].cityName + '</option>';
        }
        $form.find('select[name=city]').html(cityHtml).parent().show();
        form.render();
        form.on('select(city)', function(data) {
            var value = data.value;
            var d = value.split('_');
            var code = d[0];
            var count = d[1];
            var index = d[2];
            if (count > 0) {
                loadArea(citys[index].mallAreaList);
            } else {
                $form.find('select[name=area]').parent().hide();
            }
        });
    }
    //加载县/区数据
    function loadArea(areas) {
        var areaHtml = '';
        for (var i = 0; i < areas.length; i++) {
            areaHtml += '<option value="' + areas[i].areaCode + '" data="'+areas[i].areaName+'">' + areas[i].areaName + '</option>';
        }
        $form.find('select[name=area]').html(areaHtml).parent().show();
        form.render();
        form.on('select(area)', function(data) {
            //console.log(data);
        });
    }

</script>
</body>

</html>